package com.hmall.user.controller;

import com.hmall.user.pojo.Address;
import com.hmall.user.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class userController {
    @Autowired(required = false)
    private userService userservice;

    /**
     * 处理根据用户id查询地址列表
     * @param userId
     * @return
     */
    @GetMapping("/address/uid/{userId}")
    public List<Address> byAddresses(@PathVariable int userId){
        return userservice.byAddresses(userId);
    }

    /**
     * 处理根据addressId查询Address
     * @param addressId
     * @return
     */
    @GetMapping("/item/{addressId}")
    public Address byAddressesId(@PathVariable int addressId){
        return userservice.byAddressesId(addressId);
    }
}
